Skip to content

Conversation

@ramnes
Copy link
Contributor

@ramnes ramnes commented Dec 16, 2025

When bindStmtArgs parses binary protocol parameters, the MySQL type is available in paramTypes. However, the library loses this type information when passing the parsed values to the Handler.HandleStmtExecute callback: it converts length-encoded parameters (datetime, varchar, blob, etc.) to plain []byte and drops the type.

This creates problems for proxies: when forwarding these parameters to a backend, the client sees []byte and sends them as MYSQL_TYPE_STRING, even if the original type was MYSQL_TYPE_DATETIME or another type. Some server implementations strictly validate parameter types and reject this mismatch.

This PR introduces a simple TypedBytes struct that preserves the original MySQL type alongside the raw bytes. Handler.HandleStmtExecute callback now receives this struct instead of []byte for length-encoded parameters, and client.Stmt also handles TypedBytes by using the preserved type when sending to servers.

@lance6716
Copy link
Collaborator

lance6716 commented Dec 20, 2025

Please merge master to meet the merge requirements (somehow I can't push a merge commit from my side)

@ramnes ramnes force-pushed the ramnes/typed-bytes branch from 031be73 to 0c165f1 Compare December 20, 2025 12:48
@ramnes
Copy link
Contributor Author

ramnes commented Dec 20, 2025

rebased

@lance6716
Copy link
Collaborator

Sorry still can't merge after merge 884cd37

maybe this checkbox is not enabled?

image

@ramnes ramnes force-pushed the ramnes/typed-bytes branch from 0c165f1 to 9996cd4 Compare December 20, 2025 13:51
@ramnes
Copy link
Contributor Author

ramnes commented Dec 20, 2025

Not sure why you can't update the branch but I can't find the option so I just rebased again, no worries :)

@lance6716 lance6716 merged commit a1483a5 into go-mysql-org:master Dec 20, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants